const jwt = require('jsonwebtoken')
const process = require('node:process')
const postRefreshToken = async (req, res) => {
  const accessToken = jwt.sign({user: req.user}, process.env.SECRET_KEY, {expiresIn: '1h'})
  res.status(200).json({
    success: true,
    accessToken,
    expireToken: new Date().getTime() + 20 * 1000,
    refreshToken: req.headers.authorization.split(' ')[1],
  })
}

module.exports = {
  postRefreshToken,
}
